var config = require('../../config');
var request = require('../../support').request2;

var serviceConfig = {
  // 获取管家社区列表
  'getProjects': ['get', '/hk-api/api/json/user/getResponsibleCommunitys'],
  // 店铺订单
  'listOrder': ['get', '/hk-api/api/json/order/getOrders'],
  // 当日已处理订单
  'getTodayOrder': ['get', '/hk-api/api/json/order/getTodayOrder'],
  // 当日已处理店铺订单
  'getTodayProviderOrder': ['get', '/hk-api/api/json/order/getTodayProviderOrder'],
  // 订单搜索
  'searchOrder': ['get', '/hk-api/api/json/order/searchOrderByKeyWord'],
  // 订单详情
  'detailOrder': ['get', '/hk-api/api/json/order/getLgOrderDetail'],
  // 提交发货信息
  'setLogistics': ['get', '/hk-api/api/json/order/setLogistics'],
  // 生成订单支付二维码
  'orderPayQrCode': ['get', '/hk-api/api/json/order/getPayQuickMark'],
  // 是否扫码支付成功
  'judeOrderIsPay': ['get', '/hk-api/api/json/order/judeOrderIsPay'],
  // 现金收款
  'cashCollectFees': ['get', '/hk-api/api/json/collectFees/cashCollectFees'],
  // 店铺列表
  'listStore': ['get', '/merchant-api/api/json/shopTemplate/getShopList'],
  // 历史店铺
  'lastStore': ['get', '/merchant-api/api/json/shopTemplate/getLastShop'],
  // 历史收款
  'listPayOrder': ['get', '/merchant-api/api/json/merSKOrder/getHistoryOrderList'],
  // 生成付款二维码
  'createQrcode': ['get', '/merchant-api/api/json/merSKOrder/createQrCode'],
  // 监听二维码支付状态
  'monitorQrCode': ['get', '/merchant-api/api/json/merSKOrder/monitorQrCode']
}

Object.keys(serviceConfig).forEach(function (key) {
  var whost = config.whost
  exports[key] = function (context, data) {
    return request(context, {
      method: serviceConfig[key][0],
      url: whost + serviceConfig[key][1],
      data: data
    }).then(function (res) {
      return res;
    }, function (rej) {
      return {
        fail: true,
        message: rej.message
      };
    })
  }
});